﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PMCgui
{
    public partial class WaitDialog : Form
    {
        private const int CP_NOCLOSE_BUTTON = 512;
        protected override CreateParams CreateParams
        {
             get
             {
                CreateParams myCp = base.CreateParams;
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON ;
                return myCp;
             }
         }

        Timer timer = new Timer();
        private int currentDot = 0;
        private readonly string[] dots = new[] { "", ".", "..", "..." };
        private string text = Language.Instance.PleaseWait;

        public WaitDialog()
        {
            InitializeComponent();
            timer.Interval = 500;
            timer.Enabled = true;
            timer.Tick += new EventHandler(timer_Tick);
            Shown += new EventHandler(WaitDialog_Shown);
        }

        void WaitDialog_Shown(object sender, EventArgs e)
        {
            CenterToScreen();
        }

        void timer_Tick(object sender, EventArgs e)
        {          
            currentDot++;
            if (currentDot == dots.Length)
                currentDot = 0;

            lbWait.Text = text + dots[currentDot];
            Text = lbWait.Text;
        }
    }
}
